package model;

import java.util.GregorianCalendar;

public class Test {

	public static void main(String[] args) {
		GregorianCalendar gc = new GregorianCalendar(2008,
				GregorianCalendar.MAY, 9, 14, 12, 42);
		// -----------------------------------
		MachineType mt = new MachineType(2345678, "SP3000", "");
		// -----------------------------------
		Machine m = new Machine(1234567, "Machine01", "", mt);
		// -----------------------------------
		// -----------------------------------
		Reparation r1 = new Reparation(3132123, gc, "", m);
		System.out.println("Reparation 1: " + r1);
		// -----------------------------------
		SparePart sp = new SparePart(2203459, 331, 311, 321, "Sp", 3, 32, 7,
				"for GS20");
		SparePart sp1 = new SparePart(1111111, 111, 111, 000, "ring26", 123,
				120, 25, "for GS20");
		SparePart sp2 = new SparePart(2202334, 331, 311, 321, "Sp2", 30, 32, 7,
				"for GS32");

		sp.createSparePartHistory(r1, new SparePartUse(3, sp));
		sp1.createSparePartHistory(null, new SparePartUse(3, sp1));
		sp2.createSparePartHistory(r1, new SparePartUse(3, sp2));
		// -----------------------------------
		r1.endReparation(new GregorianCalendar(2008, GregorianCalendar.MAY, 10,
				18, 14, 32));
		System.out.println("Reparation 1: " + r1);
		System.out.println("dur: " + r1.getDurationDetail());
		System.out.println("-------------------------------------------------");
		// -----------------------------------
		GregorianCalendar gc2 = new GregorianCalendar(2008,
				GregorianCalendar.MAY, 12, 14, 12, 42);
		Reparation r2 = new Reparation(3132123, gc2, "", m);
		System.out.println("Reparation 2: " + r2);
		// -----------------------------------
		SparePart sp21 = new SparePart(2203459, 331, 311, 321, "Sp", 3, 32, 7,
				"for GS20");
		SparePart sp122 = new SparePart(1111111, 111, 111, 000, "ring26", 123,
				120, 25, "for GS20");
		SparePart sp223 = new SparePart(2202334, 331, 311, 321, "Sp2", 30, 32,
				7, "for GS32");

		sp21.createSparePartHistory(r2, new SparePartUse(3, sp21));
		sp122.createSparePartHistory(null, new SparePartUse(3, sp122));
		sp223.createSparePartHistory(r2, new SparePartUse(3, sp223));
		// -----------------------------------
		// r2.endReparation(new GregorianCalendar(2008, GregorianCalendar.MAY,
		// 16, 18, 14, 32));
		System.out.println("Reparation 2: " + r2);
		System.out.println("dur: " + r2.getDurationDetail());
		System.out.println("-------------------------------------------------");
		System.out
				.println("Reparation 1:  " + "dur: " + r1.getDurationDetail());
		System.out
				.println("Reparation 2:  " + "dur: " + r2.getDurationDetail());
		System.out.println(m.getName() + "-IdleTime: "
				+ r1.makeNiceDurPrint(m.getIdleTimeTotal()));
		System.out.println(r2);
		System.out.println(new GregorianCalendar().getTime());
		System.out.println("res: "
				+ r2.makeNiceDurPrint(r2.getIdleTime(new GregorianCalendar(
						2008, GregorianCalendar.MAY, 1))));

		System.out.println("///////////////////////////////////");

		// System.out.println(r1.getSparePartHistories());
		// System.out.println("sparePartHisories: "
		// + r1.getSparePartHistories().size());
		// // -----------------------------------
		// GregorianCalendar d = new GregorianCalendar(2008,
		// GregorianCalendar.MAY, 10);
		// int u = sp.getMonthlyUseOfSparePart(d);
		// System.out.println("MonthlyUseOfSparePart: " + u);
		// // -----------------------------------
		// GregorianCalendar start = new GregorianCalendar(2008,
		// GregorianCalendar.JANUARY, 10);
		// GregorianCalendar end = new GregorianCalendar(2008,
		// GregorianCalendar.MAY, 10);
		// int e = sp.getMonthlyUseOfSparePart(start, end);
		// System.out.println("MonthlyUseOfSparePartBetweenTwoDates: " + e);
		//
		// System.out.println(sp.getSparePartHistories());
		// System.out.println(sp2.getSparePartHistories());
	}
}